using System;
using System.IO;
using GGEditor.API.Documents;
using GGEditor.API.Editors;

namespace GGEditor.API.Samples.LandAndWater
{
	public class Importer : IFileImporter
	{
		#region Implementation of IFileImporter

		public IEditorModel Import(string filePath)
		{
			using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
			using (BinaryReader r = new BinaryReader(fileStream))
			{
				int width = r.ReadInt32();
				int height = r.ReadInt32();
				Model model = new Model(width, height);
				for (int y = 0; y < height; y++)
				{
					for (int x = 0; x < width; x++)
					{
						model[x, y] = r.ReadBoolean();
					}
				}
				return model;
			}
		}

		#endregion
	}
}